package org.zbus.thrift;

import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
import org.apache.thrift.server.TNonblockingServer;
import org.apache.thrift.server.TNonblockingServer.Args;
import org.apache.thrift.server.TServer;
import org.apache.thrift.transport.TNonblockingServerSocket;

public class ThriftServer {
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void main(String[] args) throws Exception {
		
		TNonblockingServerSocket transport = new TNonblockingServerSocket(25555);
		Factory proFactory = new TBinaryProtocol.Factory();

		TProcessor processor = new ZbusApi.Processor(new ZbusApiImpl());

		Args serverArgs = new Args(transport)
				.processor(processor)
				.protocolFactory(proFactory);

		TServer server = new TNonblockingServer(serverArgs);
		System.out.println("Start server on port 25555...");
		server.serve();
	}
}
